
#pragma comment(lib, "Ws2_32.lib")
#define _CRT_SECURE_NO_WARNINGS

#include "GroupTLV.h"
#include "SimpleTLV.h"
#include "TLVEncoder.h"
#include <stdio.h>

int main(int argc,char* argv[])
{
    uint8_t buf[1024] = {0};
    int len;

    CSimpleTLV lf1;
    lf1.setTag(1, (uint32_t)1);
    memset(buf, 0, 1024);
    len = lf1.encode(buf, 1024);
    printf("total length = %d\n", len);

    CSimpleTLV lf2;
    lf2.setTag(2, (uint64_t)0x1234567890);
    memset(buf, 0, 1024);
    len = lf2.encode(buf, 1024);
    printf("total length = %d\n", len);

    CGroupTLV com1;
    com1.setTag(3);
    com1.add(&lf1);
    com1.add(&lf2);

    memset(buf, 0, 1024);
    len = com1.encode(buf, 1024);
    printf("total length = %d\n", len);

    CTLVEncoder encoder;
    encoder.add(&lf1);
    encoder.add(&lf2);
    encoder.add(&com1);

    memset(buf, 0, 1024);
    len = encoder.encode(buf, 1024);
    printf("total length = %d\n", len);


    return 0;
}
